package com.hiwhitley.easy.day26;

/**
 * Created by hiwhitley on 2016/10/24.
 */
public class ValidPalindrome_125 {
    public boolean isPalindrome(String s) {
        if (s == null) return false;
        int size = 0;
        char[] array = new char[s.length()];
        char c;
        String up = s.toUpperCase();
        for (int i = 0; i < up.length(); i++) {
            c = up.charAt(i);
            if ((c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')) {
                array[size++] = c;
            }
        }
        if (size == 0) return true;
        int mid = size / 2, end = size - 1;
        for (int i = 0; i < mid; i++) {
            if (array[i] != array[end - i]) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        ValidPalindrome_125 main = new ValidPalindrome_125();
        main.isPalindrome("aA");
        System.out.println('a'-'A');
    }
}
